// 1. 引入axios对象
import request from '@/utils/request'

// 2. 引入ts接口类型约束 
import type { TrademarkListDataModel, TrademarkModel } from '@/api/product/model/trademarkModel'

// 3. 使用枚举来统一管理接口
enum Api {
  // 3.1. 根据页码获取对应的品牌数据
  getTrademarkInfoApi = '/admin/product/baseTrademark',
  // 3.2. 添加品牌
  saveTrademarkApi = '/admin/product/baseTrademark/save',
  // 3.3 删除品牌
  deleteTrademarkApi = '/admin/product/baseTrademark/remove',
  // 3.4 更改品牌
  updateTrademarkApi = '/admin/product/baseTrademark/update'
}


// 4. 定义一个获取品牌数据的接口函数
// export const reqGetTrademarkInfoData = (page:number,limit:number) => {
//   return request.get(`/admin/product/baseTrademark/${page}/${limit}`)
// }
// 可以简写成如下形式
// export const reqGetTrademarkInfoData = (page: number, limit: number) => request.get<any, TrademarkListDataModel>(`/admin/product/baseTrademark/${page}/${limit}`)
export const reqGetTrademarkInfoData = (page: number, limit: number) => request.get<any, TrademarkListDataModel>(`${Api.getTrademarkInfoApi}/${page}/${limit}`)

// 5. 添加品牌
export const reqSaveTrademarkInfo = (trademark: TrademarkModel) => request.post<any,null>(Api.saveTrademarkApi, trademark)

// 6. 删除某一个品牌
export const reqDeleteTrademarkInfo = (id: number) => request.delete<any,null>(Api.deleteTrademarkApi + `/${id}`)

// 7. 更新品牌
export const reqUpdateTrademarkInfo = (trademark:TrademarkModel)=>request.put<any,null>(Api.updateTrademarkApi,trademark)